package db_meta

import (
	db "engine/db"
	"gitee.com/ameise84/e3utils/str_conv"
	jsoniter "github.com/json-iterator/go"
	"servers/models/define"
)

func init() {
	db.RegisterTableMetaFactory(StatGameJackpotFactory)
}

func StatGameJackpotFactory() db.TableMeta {
	return &StatGameJackpot{}
}

type StatGameJackpot struct {
	JackpotID     uint32                `json:"id" form:"id" gorm:"primarykey;column:id"`           // 平台ID
	GameKindID    define.GameKind       `json:"game_kind" form:"game_kind" gorm:"column:game_kind"` // 积分类型
	IndexTag      int32                 `json:"index_tag" form:"index_tag" gorm:"column:index_tag"` // 奖池索引标识
	BusinessID    define.BusinessIDType `json:"bid" form:"bid" gorm:"column:bid"`
	ScoreType     define.ScoreType      `json:"score_type" form:"score_type" gorm:"column:score_type"`
	TodayIn       define.GameScore      `json:"today_in" form:"today_in" gorm:"column:today_in"`
	TodayOut      define.GameScore      `json:"today_out" form:"today_out" gorm:"column:today_out"`
	TodayLastTime int64                 `json:"today_last_time" form:"today_last_time" gorm:"column:today_last_time"`
	TotalIn       define.GameScore      `json:"total_in" form:"total_in" gorm:"column:total_in"`
	TotalOut      define.GameScore      `json:"total_out" form:"total_out" gorm:"column:total_out"`
	Score         define.GameScore      `json:"score" form:"score" gorm:"column:score"`
	RealJackpot   define.GameScore      `json:"real_jackpot" form:"real_jackpot" gorm:"column:real_jackpot"`
	UnRealJackpot define.GameScore      `json:"unreal_jackpot" form:"unreal_jackpot" gorm:"column:unreal_jackpot"`
	LockScore     define.GameScore      `json:"lock_score" form:"lock_score" gorm:"column:lock_score"`
	InOutScore    define.GameScore      `json:"in_out_score" form:"in_out_score" gorm:"column:in_out_score"`
}

func (v *StatGameJackpot) BaseTableName() string {
	return v.TableName()
}

func (v *StatGameJackpot) TableName() string {
	return "stat_game_jackpot"
}

func (v *StatGameJackpot) ID() string {
	return str_conv.ToString(v.JackpotID)
}

func (v *StatGameJackpot) MarshalBinary() (data []byte, err error) {
	return jsoniter.Marshal(v)
}

func (v *StatGameJackpot) UnmarshalBinary(data []byte) error {
	return jsoniter.Unmarshal(data, v)
}

func (v *StatGameJackpot) WhereWithBidAndKindAndTag() string {
	return "bid = ? AND game_kind = ? AND index_tag = ?"
}
